﻿Imports System.ComponentModel

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class ucPeriodDetails
    Inherits UcBaseEditControl
    Implements IUcEditControl

#Region "Designer"
    'UserControl overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

    End Sub
    Friend WithEvents DiplomaSuperTypeIdlbl As System.Windows.Forms.Label
    Friend WithEvents DiplomaSuperTypeId As org.codegen.win.controls.CGComboBox
    Friend WithEvents LastProcessDate As org.codegen.win.controls.CGTextBox
    Friend WithEvents LastProcessDateLbl As System.Windows.Forms.Label

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.PeriodCodelbl = New System.Windows.Forms.Label()
        Me.PeriodCode = New org.codegen.win.controls.CGTextBox(Me.components)
        Me.PeriodNamelbl = New System.Windows.Forms.Label()
        Me.PeriodName = New org.codegen.win.controls.CGTextBox(Me.components)
        Me.PeriodDatelbl = New System.Windows.Forms.Label()
        Me.PeriodDate = New org.codegen.win.controls.CGDateTextBox(Me.components)
        Me.DiplomaSuperTypeIdlbl = New System.Windows.Forms.Label()
        Me.DiplomaSuperTypeId = New org.codegen.win.controls.CGComboBox(Me.components)
        Me.LastProcessDate = New org.codegen.win.controls.CGTextBox(Me.components)
        Me.LastProcessDateLbl = New System.Windows.Forms.Label()
        CType(Me.ErrProvider, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'PeriodCodelbl
        '
        Me.PeriodCodelbl.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.PeriodCodelbl.Location = New System.Drawing.Point(50, 39)
        Me.PeriodCodelbl.Name = "PeriodCodelbl"
        Me.PeriodCodelbl.Size = New System.Drawing.Size(96, 20)
        Me.PeriodCodelbl.TabIndex = 2
        Me.PeriodCodelbl.Text = "Code"
        Me.PeriodCodelbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'PeriodCode
        '
        Me.PeriodCode.AssociatedLabel = Me.PeriodCodelbl
        Me.PeriodCode.BackColor = System.Drawing.Color.LightYellow
        Me.PeriodCode.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.PeriodCode.ErrProvider = Nothing
        Me.PeriodCode.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.PeriodCode.FormatPattern = Nothing
        Me.PeriodCode.isMandatory = True
        Me.PeriodCode.Location = New System.Drawing.Point(152, 39)
        Me.PeriodCode.MaxLength = 255
        Me.PeriodCode.MaxValue = Nothing
        Me.PeriodCode.MinValue = Nothing
        Me.PeriodCode.Name = "PeriodCode"
        '
        Me.PeriodCode.Size = New System.Drawing.Size(68, 21)
        Me.PeriodCode.TabIndex = 3
        '
        'PeriodNamelbl
        '
        Me.PeriodNamelbl.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.PeriodNamelbl.Location = New System.Drawing.Point(20, 65)
        Me.PeriodNamelbl.Name = "PeriodNamelbl"
        Me.PeriodNamelbl.Size = New System.Drawing.Size(126, 20)
        Me.PeriodNamelbl.TabIndex = 4
        Me.PeriodNamelbl.Text = "Period Name"
        Me.PeriodNamelbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'PeriodName
        '
        Me.PeriodName.AssociatedLabel = Me.PeriodNamelbl
        Me.PeriodName.BackColor = System.Drawing.SystemColors.ButtonFace
        Me.PeriodName.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.PeriodName.ErrProvider = Nothing
        Me.PeriodName.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.PeriodName.FormatPattern = Nothing
        Me.PeriodName.isMandatory = True
        Me.PeriodName.Location = New System.Drawing.Point(152, 65)
        Me.PeriodName.MaxLength = 255
        Me.PeriodName.MaxValue = Nothing
        Me.PeriodName.MinValue = Nothing
        Me.PeriodName.Name = "PeriodName"
        Me.PeriodName.ReadOnly = True
        '
        Me.PeriodName.Size = New System.Drawing.Size(200, 21)
        Me.PeriodName.TabIndex = 5
        '
        'PeriodDatelbl
        '
        Me.PeriodDatelbl.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.PeriodDatelbl.Location = New System.Drawing.Point(22, 13)
        Me.PeriodDatelbl.Name = "PeriodDatelbl"
        Me.PeriodDatelbl.Size = New System.Drawing.Size(124, 20)
        Me.PeriodDatelbl.TabIndex = 0
        Me.PeriodDatelbl.Text = "Period Date"
        Me.PeriodDatelbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'PeriodDate
        '
        Me.PeriodDate.AssociatedLabel = Me.PeriodDatelbl
        Me.PeriodDate.BackColor = System.Drawing.Color.LightYellow
        Me.PeriodDate.ErrProvider = Nothing
        Me.PeriodDate.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.PeriodDate.isMandatory = True
        Me.PeriodDate.Location = New System.Drawing.Point(152, 13)
        Me.PeriodDate.MaxLength = 255
        Me.PeriodDate.MaxValue = Nothing
        Me.PeriodDate.MinValue = Nothing
        Me.PeriodDate.Name = "PeriodDate"
        '
        Me.PeriodDate.Size = New System.Drawing.Size(116, 21)
        Me.PeriodDate.TabIndex = 1
        '
        'DiplomaSuperTypeIdlbl
        '
        Me.DiplomaSuperTypeIdlbl.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DiplomaSuperTypeIdlbl.Location = New System.Drawing.Point(17, 94)
        Me.DiplomaSuperTypeIdlbl.Name = "DiplomaSuperTypeIdlbl"
        Me.DiplomaSuperTypeIdlbl.Size = New System.Drawing.Size(129, 20)
        Me.DiplomaSuperTypeIdlbl.TabIndex = 7
        Me.DiplomaSuperTypeIdlbl.Text = "Diploma Type"
        Me.DiplomaSuperTypeIdlbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'DiplomaSuperTypeId
        '
        Me.DiplomaSuperTypeId.AssociatedLabel = Me.DiplomaSuperTypeIdlbl
        Me.DiplomaSuperTypeId.BackColor = System.Drawing.Color.LightYellow
        Me.DiplomaSuperTypeId.ErrProvider = Nothing
        Me.DiplomaSuperTypeId.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.DiplomaSuperTypeId.isMandatory = True
        Me.DiplomaSuperTypeId.Location = New System.Drawing.Point(152, 92)
        Me.DiplomaSuperTypeId.MaxLength = 255
        Me.DiplomaSuperTypeId.MaxValue = Nothing
        Me.DiplomaSuperTypeId.MinValue = Nothing
        Me.DiplomaSuperTypeId.Name = "DiplomaSuperTypeId"

        Me.DiplomaSuperTypeId.Size = New System.Drawing.Size(345, 21)
        Me.DiplomaSuperTypeId.TabIndex = 6
        '
        'LastProcessDate
        '
        Me.LastProcessDate.AssociatedLabel = Me.LastProcessDateLbl
        Me.LastProcessDate.BackColor = System.Drawing.SystemColors.ButtonFace
        Me.LastProcessDate.ErrProvider = Nothing
        Me.LastProcessDate.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.LastProcessDate.FormatPattern = Nothing
        Me.LastProcessDate.isMandatory = True
        Me.LastProcessDate.Location = New System.Drawing.Point(152, 123)
        Me.LastProcessDate.MaxLength = 255
        Me.LastProcessDate.MaxValue = Nothing
        Me.LastProcessDate.MinValue = Nothing
        Me.LastProcessDate.Name = "LastProcessDate"
        Me.LastProcessDate.ReadOnly = True
        '
        Me.LastProcessDate.Size = New System.Drawing.Size(345, 21)
        Me.LastProcessDate.TabIndex = 9
        '
        'LastProcessDateLbl
        '
        Me.LastProcessDateLbl.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.LastProcessDateLbl.Location = New System.Drawing.Point(22, 123)
        Me.LastProcessDateLbl.Name = "LastProcessDateLbl"
        Me.LastProcessDateLbl.Size = New System.Drawing.Size(124, 20)
        Me.LastProcessDateLbl.TabIndex = 8
        Me.LastProcessDateLbl.Text = "Last Process Date"
        Me.LastProcessDateLbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'ucPeriodDetails
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange
        Me.Controls.Add(Me.LastProcessDate)
        Me.Controls.Add(Me.LastProcessDateLbl)
        Me.Controls.Add(Me.DiplomaSuperTypeIdlbl)
        Me.Controls.Add(Me.DiplomaSuperTypeId)
        Me.Controls.Add(Me.PeriodDate)
        Me.Controls.Add(Me.PeriodCodelbl)
        Me.Controls.Add(Me.PeriodCode)
        Me.Controls.Add(Me.PeriodNamelbl)
        Me.Controls.Add(Me.PeriodName)
        Me.Controls.Add(Me.PeriodDatelbl)
        Me.Name = "ucPeriodDetails"
        Me.Size = New System.Drawing.Size(803, 189)
        CType(Me.ErrProvider, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

    

    Friend WithEvents PeriodCodelbl As System.Windows.Forms.Label
    Friend WithEvents PeriodCode As CGTextBox
    Friend WithEvents PeriodNamelbl As System.Windows.Forms.Label
    Friend WithEvents PeriodName As CGTextBox
    Friend WithEvents PeriodDatelbl As System.Windows.Forms.Label
    Friend WithEvents PeriodDate As CGDateTextBox


#End Region

#Region "Properties"


#End Region

#Region "Methods"


    ''' <summary>
    ''' Fills the controls on the screen from data in the object
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub _loadData() Handles Me.evLoadObjectData

        Dim mo As Period = DirectCast(Me.ModelObject(), Period)
        Me.PeriodCode.value = mo.PeriodCode
        Me.PeriodName.value = mo.PeriodName
        Me.PeriodDate.value = mo.PeriodDate
        Me.DiplomaSuperTypeId.Value = mo.DiplomaSuperTypeId

        'set readonly = true if isopen = false
        Me.PeriodDate.ReadOnly = Not mo.IsOpen.GetValueOrDefault

        Dim p As List(Of PeriodProcess) = PeriodProcessDataUtils.findList("periodid={0} order by PeriodProcessDate desc", mo.PeriodId)
        If p.Count > 0 Then
            Me.LastProcessDate.value = Format(p(0).PeriodProcessDate, "G")
        Else
            Me.LastProcessDate.value = "Never Processed"
        End If

    End Sub

  

    ''' <summary>
    ''' Loads the object from the database and then sets the proeperties 
    ''' of the object from values on the controls
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub _loadToObject() Handles Me.evLoadToObject

        Dim mo As Period = DirectCast(Me.ModelObject, Period)
        mo.setPeriodCode(Me.PeriodCode.Text)
        mo.setPeriodName(Me.PeriodName.Text)
        mo.setPeriodDate(Me.PeriodDate.Text)
        mo.DiplomaSuperTypeId = Me.DiplomaSuperTypeId.intValue

    End Sub


	Public Sub _InitializeControl() Handles Me.InitializeControl

		If Me.isInitialized = False Then
			'setup datasources here
            Dim swhere As String = ""
            If Me.ModelObject.isNew Then
                swhere = "isActive=1" 'only bring active diploma types
            End If
            Me.DiplomaSuperTypeId.DataSource = DiplomaSuperTypeDataUtils.findList(swhere)
			Me.DiplomaSuperTypeId.ValueMember = "DiplomaSuperTypeId"
			Me.DiplomaSuperTypeId.DisplayMember = "DiplomaSuperTypeCode"

			Me.isInitialized = True
		End If

	End Sub

#End Region

    Private Sub PeriodDate_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles PeriodDate.LostFocus

        ' after change of period date, load a new object and execute 
        ' set setPeriodDate to get new values for  name and code of period
        Dim mo As Period = CType(Me.ModelObject, Period)
        mo.setPeriodDate(Me.PeriodDate.Text)

        Me.PeriodName.Text = mo.PeriodName
        'Me.PeriodCode.Text = mo.PeriodCode

    End Sub
End Class


